package cn.javass.xgen.util.readxml;

import org.w3c.dom.Element;

import java.util.List;

/**
 * 多个属性终结符
 */
public class PropertiesTerminalExpression extends ReadXmlExpression {

    private String propName;

    public PropertiesTerminalExpression(String propeName) {
        this.propName = propeName;
    }

    @Override
    public String[] interpret(Context ctx) {

        //1.获取父元素
        List<Element> pEles = ctx.getPreEles();
        //2.取该元素的属性值
        String[] ss = new String[pEles.size()];
        for (int i = 0; i < ss.length; i++) {
            ss[i] = pEles.get(i).getAttribute(propName);
        }
        return ss;
    }
}
